package com.ruoyi.workflow.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisPlusConfig {

    /**
     * 配置 MybatisPlus 的分页拦截器
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        //1.MybatisPlus 拦截器  MybatisPlusInterceptor
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //2.分页拦截器 PaginationInnerInterceptor
        PaginationInnerInterceptor innerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
        //3.设置分页插件的属性,溢出总页数后进行处理
        innerInterceptor.setOverflow(true);
        //4.把分页拦截器添加到MyBatisPlus的拦截器中
        interceptor.addInnerInterceptor(innerInterceptor);
        return interceptor;

    }
}
